'use strict';

const Controller = require('../core/base_controller');

/**
 * Controller - 送货时间
 * @class
 * @author ruiyong-lee
 */
const { Parser } = require('sql-ddl-to-json-schema');
class MysqlBaseController extends Controller {
  /**
   * 新增送货时间
   */
  async passddl() {
    const { ctx } = this;
    const parser = new Parser('mysql');

    const body=ctx.request.body;
    console.log("> ctx body", body);
    if(!body.ddl){
      return this.fail(500,"参数ddl是必须的")
    }
    const sql=body.ddl;
    const jsonSchemaDocuments = parser.feed(sql).toJsonSchemaArray({});
    return this.success(jsonSchemaDocuments&&jsonSchemaDocuments[0],200);

    // const rule = {
    //   deliveryTimeType: 'object',
    // };
    // ctx.validate(rule);
    // const uuid = await ctx.service.deliveryTimeType.saveNew(ctx.request.body);
    // this.success(uuid);
     
  }

 
}

module.exports = MysqlBaseController;
